<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<title>EaselJS: Filters Example</title>

	<link href="../_assets/css/shared.css" rel="stylesheet" type="text/css"/>
	<link href="../_assets/css/examples.css" rel="stylesheet" type="text/css"/>
	<script src="../_assets/js/examples.js"></script>

	<script src="../lib/easeljs-NEXT.js"></script>
	<!-- We also provide hosted minified versions of all CreateJS libraries.
	  http://code.createjs.com -->

<script id="editable">
	var img;
	var bmp;
	var stage;
	var angle;
	var canvas;
	var range;
	var speed;

	function init() {
		angle = 0;
		range = 30;
		speed = 0.02;
		img = new Image();
		img.onload = handleImageLoad;
		img.src = "../_assets/art/flowers.jpg";
	}

	function handleImageLoad() {
		canvas = document.getElementById("testCanvas");
		stage = new createjs.Stage(canvas);

		bmp = new createjs.Bitmap(img).set({y: (canvas.height - img.height) / 2});
		bmp.cache(0, 0, img.width, img.height);

		stage.addChild(bmp);

		createjs.Ticker.addEventListener("tick", tick);
	}

	function tick(event) {
		angle += speed;

		var value = (Math.sin(angle) + 1) / 2 * range;
		bmp.updateCache();
		bmp.filters = [new createjs.BlurFilter(value, value, 2)];

		stage.update(event);
	}

</script>
</head>
<body onload="init()">

<header class="EaselJS">
	<h1>BlurFilter</h1>

	<p>This sample loads an image, and applies a <code>BlurFilter</code> each
		tick with a varying value.</p>
</header>

<canvas id="testCanvas" width="960" height="400"></canvas>

</body>
</html>
